<template>
  <div>
    <a-form-model-item label="用户名">
      <a-input v-model="form.username" placeholder="请输入用户名" />
    </a-form-model-item>

    <a-form-model-item label="密码">
      <a-input v-model="form.password" placeholder="请输入密码" />
    </a-form-model-item>

    <a-button type="primary" @click="login">
      登&emsp;录
    </a-button>
  </div>
</template>

<script>
export default {
name: "ant_login",
  data(){
   return{
     form:{
       username:'',
       password:'',
     }
   }
  },
  methods:{
    login(){
      let UserInfo=new FormData()
      UserInfo.append("username",this.form.username)
      UserInfo.append("password",this.form.password)
      this.$axios.post('/z/login/',UserInfo)
      .then(res=>{
        console.log(res.data)
        if(res.data.code==200){
          localStorage.setItem('user_level',res.data.user_level)
          localStorage.setItem('uid',res.data.id)
          this.$router.push('/myback')
        }
        // alert(res.data.msg)
      })

    }
  }
}
</script>

<style scoped>

</style>
